package com.abu.apply.config.mvc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Component
public class MvcConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptorConfig;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        List<String> excludePathList = new ArrayList<>(2);
        excludePathList.add("/apply/noAuthorize/**");

//        默认路径必须（登录成功）认证后才能访问资源信息
        registry.addInterceptor(loginInterceptorConfig)
                .addPathPatterns("/**")
                .excludePathPatterns(excludePathList);
    }

}

